<ui:composition xmlns="http://www.w3.org/1999/xhtml"
	xmlns:s="http://jboss.com/products/seam/taglib"
	xmlns:ui="http://java.sun.com/jsf/facelets"
	xmlns:f="http://java.sun.com/jsf/core"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:rich="http://richfaces.org/rich"
	xmlns:a="http://richfaces.org/a4j"
	template="/applications/applications-frame.xhtml">

	<ui:param name="pageTitle"
		value="#{messages['page.applications.index.title']}" />

	<ui:define name="subheader">#{messages['page.applications.index.subheader']}</ui:define>

	<ui:define name="main">
		<a:form id="applicationListForm">

			<rich:extendedDataTable value="#{applicationBean.getAll()}"
				var="applicationx" sortMode="single" rows="20"
				onRowMouseOver="this.className='extdt-row-selected'"
				onRowMouseOut="this.className=''" id="applicationListTable">
				<f:facet name="header">
					<h:panelGroup>
						<h:commandLink action="#{applicationBean.create()}"
							style="float:left; background-color: transparent;">
							<h:outputText value="#{messages['application.create']}" />
						</h:commandLink>
					</h:panelGroup>
				</f:facet>

				<rich:column sortable="true" sortBy="#{applicationx.name}"
					filterBy="#{applicationx.name}"
					label="#{messages['application.name']}" width="25%">
					<f:facet name="header">#{messages['application.name']}</f:facet>
					<h:outputText value="#{applicationx.name}" />
				</rich:column>

				<rich:column sortable="true"
					sortBy="#{applicationx.applicant.lastname} #{applicationx.applicant.firstname}"
					filterBy="#{applicationx.applicant.lastname} #{applicationx.applicant.firstname}"
					label="#{messages['application.customer.name']}" width="20%">
					<f:facet name="header">#{messages['application.customer.name']}</f:facet>
					<h:outputText value="#{applicationx.applicant.lastname} #{applicationx.applicant.firstname}" />
				</rich:column>

				<rich:column sortable="true"
					sortBy="#{applicationx.applicant.pesel}"
					filterBy="#{applicationx.applicant.pesel}"
					label="#{messages['application.customer.pesel']}" width="15%">
					<f:facet name="header">#{messages['application.customer.pesel']}</f:facet>
					<h:outputText value="#{applicationx.applicant.pesel}" />
				</rich:column>

				<rich:column sortable="true" sortBy="#{applicationx.amount}"
					filterBy="#{applicationx.amount}"
					label="#{messages['application.amount']}" width="20%">
					<f:facet name="header">#{messages['application.amount']}</f:facet>
					<h:outputText value="#{applicationx.amount}" />
				</rich:column>
                
                <rich:column label="#{messages['application.state']}" width="20%">
					<f:facet name="header">#{messages['application.state']}</f:facet>
					<h:outputText value="#{applicationx.state.label}" />
				</rich:column>

				<a:support event="onRowClick"
					action="#{applicationBean.setSelectedApplication(applicationx)}" />

				<f:facet name="footer">
					<rich:datascroller for="applicationListTable"
						id="applicationListTableScroller" />
				</f:facet>
			</rich:extendedDataTable>
		</a:form>

	</ui:define>
</ui:composition>
